home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / refresh.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  3.1 KB  |  100 lines

  1.  
  2. //form field names:
  3. //fileURL - text field where URL appears
  4. //Delay - form field for delay number
  5. //Action - radio buttons: radioURL is Go To another document
  6. //                        radioThisDoc is stay at current document
  7.  
  8. // *********** GLOBAL VARS *****************************
  9.  
  10. var helpDoc = MM.HELP_inspRefresh;
  11.  
  12. // ******************** API ****************************
  13. function canInspectSelection(){
  14.  
  15.   var metaObj = getSelectedObj();
  16.   return (metaObj.tagName && metaObj.tagName=="META" &&
  17.           metaObj.getTranslatedAttribute("http-equiv") && 
  18.           metaObj.getTranslatedAttribute("http-equiv").toLowerCase()=="refresh");
  19.    
  20. }
  21.  
  22. function inspectSelection(){
  23.   var refreshObj = getSelectedObj()
  24.   var tagContent = refreshObj.getAttribute("content"); 
  25.   var Delay = findObject("Delay");
  26.   var radioURL = findObject("radioURL");var radioThisDoc = findObject("radioThisDoc");
  27.   var contentArray;
  28.   
  29.   
  30.   //fill in PI form fields
  31.   //check to see if the refresh applies to the current document by doing
  32.   // an integer check - URL will have a ; 
  33.   if (tagContent == parseInt(tagContent)){ 
  34.     //fill in the Delay value and check the correct radio button:
  35.     Delay.value = tagContent; 
  36.     radioThisDoc.checked = true;     radioURL.checked = false;
  37.   } else {               // else refresh is used to go to another document
  38.      contentArray = getTokens(tagContent,";"); //create 2-member array
  39.      //fill in the Delay value
  40.      Delay.value = (parseInt(contentArray[0])==contentArray[0])?contentArray[0]:""; 
  41.      //check correct radio button:
  42.      radioURL.checked = true;     radioThisDoc.checked = false;
  43.      //strip "URL=" before placing into PI
  44.      if (contentArray[1] && contentArray[1].indexOf("URL=")==0) 
  45.        contentArray[1] = contentArray[1].substring(4);  
  46.      //fill in correct URL value  
  47.      if (contentArray[1])
  48.        findObject("fileURL").value = contentArray[1];
  49.      else
  50.        findObject("fileURL").value="";  
  51.   }
  52.  
  53.   showHideTranslated();
  54. }
  55.  
  56.  
  57. // ******************** LOCAL FUNCTIONS ****************************
  58.  
  59. function clearField(){
  60.   findObject("fileURL").value="";
  61.  
  62. }
  63.  
  64. function setMetaTag(whichButton){
  65.   //if whichButton is 0, go to URL just checked. If 1, refresh this doc just checked
  66.   //if 2, this function called from a form field other than a checkbox
  67.   var fileName="",refreshContent="";
  68.   var radioURL = findObject("radioURL");
  69.   var radioThisDoc = findObject("radioThisDoc");
  70.   var fileURL = findObject("fileURL");
  71.   var Delay = findObject("Delay");
  72.   var refreshDelay = (parseInt(Delay.value) == Delay.value)?Delay.value:"";
  73.   
  74.   if (whichButton == 0 || (whichButton == 2 && radioURL.checked && !radioThisDoc.checked)){
  75.   //if going to another doc
  76.     fileName=(fileURL.value)?fileURL.value:"";
  77.     refreshContent=refreshDelay + ";URL=" + fileName;
  78.     //set checkboxes correctly
  79.     radioThisDoc.checked = false;
  80.     radioURL.checked=true;
  81.   }
  82.   else { //refresh current doc
  83.     refreshContent=refreshDelay;
  84.     //set checkboxes correctly
  85.     radioURL.checked = false;
  86.     radioThisDoc=true;
  87.   }
  88.   
  89.   getSelectedObj().setAttribute("content",refreshContent);
  90.   
  91. }
  92.  
  93.  
  94. function browseForFile(){
  95.   var File = browseForFileURL(); 
  96.   if (File)
  97.     findObject("fileURL").value = File;
  98. }
  99.  
  100.